/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.yuecai.modules.yc_category.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.Instant;

/**
* @website https://el-admin.vip
* @description /
* @author dm
* @date 2020-06-24
**/
@Entity
@Data
@Table(name="yc_category")
public class YcCategory implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

    @Column(name = "name",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "分类名称")
    private String name;

    @Column(name = "pic")
    @ApiModelProperty(value = "图标")
    private String pic;

    @Column(name = "status")
    @ApiModelProperty(value = "分类状态1.启用 0禁用")
    private Boolean status;

    @Column(name = "sort")
    @ApiModelProperty(value = "分类排序")
    private Integer sort;

    @Column(name = "create_time",nullable = false)
    @ApiModelProperty(value = "添加时间")
    private Instant createTime;

    @Column(name = "update_time",nullable = false)
    @ApiModelProperty(value = "修改时间")
    private Instant updateTime;

    @Column(name = "up_id")
    @ApiModelProperty(value = "上级分类Id （一级分类为空）")
    private Long upId;


    @Column(name = "is_show_home")
    @ApiModelProperty(value = "是否在首頁顯示")
    private Boolean isShowHome;


    public void copy(YcCategory source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}